#include <iostream>
using namespace std;

class C {

	public:
	
	C(const C& c) : __flag(c.__flag)  {
				cout << "ctor 2 " << endl;
				cout << "deep copying ... " << endl;
				__data = new double(*(double*)c.__data);
			}

	C(const double& f=0.0): __flag(true) {
		cout << "ctor 1 " << endl;
		cout << "creating data " << endl;
		__data = new double(f);
	}

	~C() { if (__flag)
			{
			cout << "deleting data " << endl;
			delete (double*)__data; 
			}
	}

	const C& check() {

		return *this;
	}

	private:
			bool __flag;
			void* __data;
			C(C& c) : __data(c.__data),__flag(c.__flag) {
			
			cout << "ctor 0 " << endl;
			c.__flag = false;
	
	}

};

int main() {
	C c;
	C c1(const_cast<const C&>(c));
	const C c2(const_cast<const C&>(c));
	C c3(c2);
	c=c.check();
	C& cf=c;
	C d=cf;
	return 0;
}
